package com.bluefish.bltuan.permalink;

import com.applerao.urlrewriter.permalink.PermalinkVariable;
import com.bluefish.bltuan.module.shop.TuanGou;

public enum ShopPermalinkVariable implements PermalinkVariable<TuanGou>{
	
	TUANGOU_NICK("%{tuangou_nick}"){
		@Override
		public String pattern() {
			return "(\\w+)";
		}
		
		@Override
		public String encode(TuanGou obj) {
			return obj.getNick();
		}
	},

	TUANGOU_CITY("%{tuangou_city}"){
		@Override
		public String pattern() {
			return "(\\w+)";
		}
		
		@Override
		public String encode(TuanGou obj) {
			return obj.getCity().getNickname();
		}
	};
	
	private String variable;

	private ShopPermalinkVariable(String variable){
		this.variable = variable;
	}
	
	public abstract String encode(TuanGou obj);

	public String getVariable(){
		return this.variable;
	}

	public abstract String pattern();

}
